#include "propertyframe.h"
#include <QLayout>
PropertyFrame::PropertyFrame(QWidget *parent)
	: QFrame(parent)
{
	groupManager = new QtGroupPropertyManager(this);
	boolManager = new QtBoolPropertyManager(this);
	intManager = new QtIntPropertyManager(this);
	doubleManager = new QtDoublePropertyManager(this);
	stringManager = new QtStringPropertyManager(this);
	sizeManager = new QtSizePropertyManager(this);
	rectManager = new QtRectPropertyManager(this);
	sizePolicyManager = new QtSizePolicyPropertyManager(this);
	enumManager = new QtEnumPropertyManager(this);

	checkBoxFactory = new QtCheckBoxFactory(this);
	spinBoxFactory = new QtSpinBoxFactory(this);
	sliderFactory = new QtSliderFactory(this);
	doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this);
	scrollBarFactory = new QtScrollBarFactory(this);
	lineEditFactory = new QtLineEditFactory(this);
	comboBoxFactory = new QtEnumEditorFactory(this);

	editor = new QtTreePropertyBrowser();

	editor->setFactoryForManager(boolManager, checkBoxFactory);
	editor->setFactoryForManager(intManager, spinBoxFactory);
	editor->setFactoryForManager(doubleManager, doubleSpinBoxFactory);
	editor->setFactoryForManager(stringManager, lineEditFactory);
	editor->setFactoryForManager(sizeManager->subIntPropertyManager(), spinBoxFactory);
	editor->setFactoryForManager(rectManager->subIntPropertyManager(), spinBoxFactory);
	editor->setFactoryForManager(sizePolicyManager->subIntPropertyManager(), spinBoxFactory);
	editor->setFactoryForManager(sizePolicyManager->subEnumPropertyManager(), comboBoxFactory);
	editor->setFactoryForManager(enumManager, comboBoxFactory);


	//QtProperty * itemImage = groupManager->addProperty(tr("Image"));
	//QtProperty * itemName = stringManager->addProperty(tr("Name"));
	//itemImage->addSubProperty(itemName);

	//QtProperty * itemFrame = groupManager->addProperty(tr("Frame"));
	//QtProperty * itemFrameName = stringManager->addProperty(tr("Name"));
	//QtProperty * itemRotated = boolManager->addProperty(tr("Rotated"));
	//QtProperty * itemRect = rectManager->addProperty(tr("Rect"));
	//QtProperty * itemSize = sizeManager->addProperty("Offset");
	//QtProperty * itemOriginalSize = sizeManager->addProperty("OriginalSize");
	//itemFrame->addSubProperty(itemFrameName);
	//itemFrame->addSubProperty(itemRect);
	//itemFrame->addSubProperty(itemRotated);
	//itemFrame->addSubProperty(itemSize);
	//itemFrame->addSubProperty(itemOriginalSize);

	//editor->addProperty(itemImage);
	//editor->addProperty(itemFrame);
	QVBoxLayout *layout = new QVBoxLayout;
	layout->setContentsMargins(0,0,0,0);
	layout->addWidget(editor);
	setLayout(layout);

	connect(stringManager,SIGNAL(valueChanged(QtProperty *, const QString &)),this,SLOT(StringValueChanged(QtProperty *, const QString &)));
	connect(boolManager,SIGNAL(valueChanged(QtProperty *, bool)),this,SLOT(BoolValueChanged(QtProperty *,bool)));
	connect(intManager,SIGNAL(valueChanged(QtProperty *, int)),this,SLOT(IntValueChanged(QtProperty *, int)));
	connect(sizeManager,SIGNAL(valueChanged(QtProperty *, const QSize &)),this,SLOT(SizeValueChanged(QtProperty *, const QSize &)));
	connect(rectManager,SIGNAL(valueChanged(QtProperty *, const QRect &)),this,SLOT(RectValueChanged(QtProperty *, const QRect &)));
	connect(sizePolicyManager,SIGNAL(valueChanged(QtProperty *, const QSizePolicy &)),this,SLOT(SizePolicyValueChanged(QtProperty *, const QSizePolicy &)));
	connect(enumManager,SIGNAL(valueChanged(QtProperty *, int)),this,SLOT(EnumPolicyValueChanged(QtProperty *, int)));

}

PropertyFrame::~PropertyFrame()
{

}


void PropertyFrame::StringValueChanged( QtProperty * prop, const QString & value )
{
	//QString probName = prop->propertyName();
	return;
}

void PropertyFrame::BoolValueChanged( QtProperty * prop, bool value )
{
	//QString probName = prop->propertyName();
	return;
}

void PropertyFrame::IntValueChanged( QtProperty * prop, int value )
{
	//QString probName = prop->propertyName();
	return;
}

void PropertyFrame::SizeValueChanged( QtProperty * prop, const QSize & value )
{
	//QString probName = prop->propertyName();
	return;
}

void PropertyFrame::RectValueChanged( QtProperty * prop, const QRect & value )
{
	//QString probName = prop->propertyName();
	return;
}

void PropertyFrame::SizePolicyValueChanged( QtProperty * prop, const QSizePolicy & value )
{
	QString probName = prop->propertyName();
	return;
}

void PropertyFrame::EnumPolicyValueChanged( QtProperty * prop, int value )
{
	//QString probName = prop->propertyName();
	return;
}

void PropertyFrame::DoubleValueChanged( QtProperty * prop, int value )
{
	//QString probName = prop->propertyName();
	return;
}
